package cn.iocoder.yudao.module.mqtt.dal.mysql.devicedriver;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mqtt.dal.dataobject.devicedriver.DeviceDriverDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mqtt.controller.admin.devicedriver.vo.*;

/**
 * 设备驱动 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface DeviceDriverMapper extends BaseMapperX<DeviceDriverDO> {

    default PageResult<DeviceDriverDO> selectPage(DeviceDriverPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceDriverDO>()
                .eqIfPresent(DeviceDriverDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(DeviceDriverDO::getCommPortId, reqVO.getCommPortId())
                .likeIfPresent(DeviceDriverDO::getDriverName, reqVO.getDriverName())
                .eqIfPresent(DeviceDriverDO::getBrand, reqVO.getBrand())
                .eqIfPresent(DeviceDriverDO::getModel, reqVO.getModel())
                .eqIfPresent(DeviceDriverDO::getDeviceAddress, reqVO.getDeviceAddress())
                .betweenIfPresent(DeviceDriverDO::getMinCollectTime, reqVO.getMinCollectTime())
                .betweenIfPresent(DeviceDriverDO::getCommWaitTime, reqVO.getCommWaitTime())
                .eqIfPresent(DeviceDriverDO::getInt16AddressRange, reqVO.getInt16AddressRange())
                .eqIfPresent(DeviceDriverDO::getInt3264AddressRan, reqVO.getInt3264AddressRan())
                .eqIfPresent(DeviceDriverDO::getFloat3264AddressRange, reqVO.getFloat3264AddressRange())
                .eqIfPresent(DeviceDriverDO::getStringByteOrder, reqVO.getStringByteOrder())
                .eqIfPresent(DeviceDriverDO::getStringEncoding, reqVO.getStringEncoding())
                .eqIfPresent(DeviceDriverDO::getBlockCollectMode, reqVO.getBlockCollectMode())
                .eqIfPresent(DeviceDriverDO::getCodeWrite, reqVO.getCodeWrite())
                .betweenIfPresent(DeviceDriverDO::getCommIntervalTime, reqVO.getCommIntervalTime())
                .eqIfPresent(DeviceDriverDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(DeviceDriverDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeviceDriverDO::getId));
    }

}